package com.deruan.hotcore.resource.action;

import java.awt.event.ActionEvent;

import org.columba.api.gui.frame.IFrameMediator;
import org.columba.core.command.CommandProcessor;
import org.columba.core.gui.action.AbstractColumbaAction;
import org.columba.mail.command.IMailFolderCommandReference;
import org.columba.mail.folder.IMailbox;
import org.columba.mail.gui.frame.MailFrameMediator;
import org.columba.mail.gui.table.action.ClearHeaderlistAction;
import org.columba.mail.gui.table.command.ViewHeaderListCommand;
import org.columba.mail.gui.table.command.ViewResourceHeaderListCommand;

import com.deruan.hotcore.resource.command.ResultCommandReference;
import com.deruan.hotcore.resource.command.SeeSocialNodeCommand;
import com.deruan.hotcore.resource.command.ViewMessageResultCommand;
import com.deruan.hotcore.resource.gui.tree.ContactTreeNode;
import com.deruan.hotcore.resource.gui.tree.MessageSearchNode;
import com.deruan.hotcore.resource.gui.tree.ResourceTreeNode;
import com.deruan.hotcore.resource.gui.tree.ResultRootNode;
import com.deruan.hotcore.resource.gui.tree.ResultTreeNode;

public class SeeSocialNodeAction extends AbstractColumbaAction
{
	public SeeSocialNodeAction(IFrameMediator controller) {
		super(controller, "SeeSocialNodeAction");
	}

	/**
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent evt) {
		ResultCommandReference references;
		if(evt==null)
		{
			references = (ResultCommandReference)(((MailFrameMediator) getFrameMediator()).getResultTreeSelection());
			if(references!=null&& (references.getSelectedNode() instanceof ResultTreeNode)){
               
				if(references.getSelectedNode() instanceof ResourceTreeNode || 
						references.getSelectedNode() instanceof ContactTreeNode)
				{
					CommandProcessor.getInstance().addOp(
							new SeeSocialNodeCommand(getFrameMediator(), references));
				}
				else if(references.getSelectedNode() instanceof MessageSearchNode)
				{
					CommandProcessor.getInstance().addOp(
							new ViewMessageResultCommand(getFrameMediator(), references));
				}

			}
			else {
				// clear message list viewer
				//new ClearHeaderlistAction(getFrameMediator()).actionPerformed(evt);
			}
            
		}
	}

}
